﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WXYW.BLL;

namespace WXYW
{
    public partial class SearchSparePart : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ServiceStationService stationService = new ServiceStationService();
                platformDropdownList.DataSource = stationService.GetAllWithSelectOne();
                platformDropdownList.DataTextField = "Name";
                platformDropdownList.DataValueField = "ID";
                platformDropdownList.DataBind();
            }
        }

        protected void searchButton_Click(object sender, EventArgs e)
        {
            SparePartService sparePartService = new SparePartService();
            resultGridView.DataSource = sparePartService.SearchSpareParts(materialNumberTxtBox.Text, modelNumberTxtBox.Text, versionNumberTxtBox.Text, Convert.ToInt32(platformDropdownList.SelectedValue), badOrGoodDropdownList.SelectedValue);
            resultGridView.DataBind();
        }

        protected void resultGridView_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.DataItem != null)
            {
                e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#FFFF99'");
                e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
                ((Label)e.Row.FindControl("IDLbl")).Text = (e.Row.RowIndex + 1).ToString();
            }
        }
    }
}
